package org.mspring.mlog.service;

import java.util.List;
import org.mspring.mlog.dao.ArticleDao;
import org.mspring.mlog.entity.Article;
import org.mspring.nbee.orm.dao.sql.builder.part.condition.SqlCondition;
import org.mspring.nbee.orm.dao.sql.pager.PageResult;
import org.mspring.nbee.orm.dao.sql.pager.Pager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Gao Youbo
 * @since 2014-12-04 17:59:00
 */
@Service
public class ArticleService {

    private static final Logger log = LoggerFactory.getLogger(ArticleService.class);

    private ArticleDao articleDao;

    public Article findById(long id) {
        return articleDao.findById(id);
    }

    public PageResult<Article> list(List<SqlCondition> conditions, Pager pager) {
        return articleDao.listPage(conditions, pager);
    }

    @Transactional
    public boolean update(Article article) {
        return articleDao.update(article);
    }

    @Transactional
    public boolean deleteById(long id) {
        return articleDao.deleteById(id);
    }

    @Autowired
    public void setArticleDao(ArticleDao articleDao) {
        this.articleDao = articleDao;
    }

}